<template>
    <div>
        <TinternshipDesire v-if="internshipDesire" @onItemData="onItemData" :itemData="itemData"></TinternshipDesire>
        <TeducationalExperience v-if="educationalExperience"  @onItemData="onItemData" :itemData="itemData"></TeducationalExperience>
        <TworkExperience v-if="workExperience"  @onItemData="onItemData" :itemData="itemData"></TworkExperience>
        <TprojectExperience v-if="projectExperience"  @onItemData="onItemData" :itemData="itemData"></TprojectExperience>
        <!-- 语言 -->
        <TlanguageAbility v-if="languageAbility" @onItemData="onItemData" :itemData="itemData"></TlanguageAbility>
        <TspecialtyAbility v-if="specialtyAbility"  @onItemData="onItemData" :itemData="itemData"></TspecialtyAbility>
        <Tcertificates v-if="certificates" @onItemData="onItemData" :itemData="itemData" ></Tcertificates>
        <Tcourses v-if="courses" @onItemData="onItemData" :itemData="itemData"></Tcourses>
        <TpracticeExperience v-if="practiceExperience" @onItemData="onItemData" :itemData="itemData"></TpracticeExperience>
        <TuserInfo v-if="userInfo" @onItemData="onItemData" :itemData="itemData"></TuserInfo>
        <!-- <van-form @submit="submit">
            <div class="form_box">
                <div class="form_item">
                    <div class="title">教育经历</div>
                    <div class="form_item_content">
                        <div class="item_title">学校名称</div>
                        <div class="item_input">
                            <van-field class="input_content" v-model="form.educationalExperience.schoolName" placeholder="请输入学校名称" />
                        </div>
                    </div>
                    <div class="form_item_content">
                        <div class="item_title">最高学历</div>
                        <div class="item_input">
                            <van-field class="input_content" v-model="form.educationalExperience.expectedIndustry" placeholder="请选择最高学历" @click="educationShowPicker = true"/>
                                <van-popup v-model="educationShowPicker" position="bottom">
                                    <van-picker
                                        show-toolbar
                                        value-key="label"
                                        :columns="education"
                                        @confirm="pickerConfirm($event, 'educationalExperience', 'expectedIndustry', 'educationShowPicker')"
                                        @cancel="educationShowPicker = false"
                                    />
                                </van-popup>
                            <div class="select_btn">请选择</div>
                        </div>
                    </div>
                    <div class="form_item_content">
                        <div class="item_title">全日制/非全日制</div>
                        <div class="item_input">
                            <van-field class="input_content"  v-model="form.educationalExperience.targetCity" readonly clickable name="picker" placeholder="" />
                            <van-radio-group v-model="form.educationalExperience.targetCity" direction="horizontal">
                                <van-radio name="1">全日制</van-radio>
                                <van-radio name="0">非全日制</van-radio>
                            </van-radio-group>
                        </div>
                    </div>
                    <div class="form_item_content">
                        <div class="item_title">学位证书</div>
                        <div class="item_input">
                            <van-field class="input_content"  v-model="form.internshipDesire.diploma" readonly clickable name="picker" placeholder="" />
                            <van-radio-group v-model="form.internshipDesire.diploma" direction="horizontal">
                                    <van-radio name="1">有</van-radio>
                                    <van-radio name="0">无</van-radio>
                                </van-radio-group>
                        </div>
                    </div>
                    <div class="form_item_content">
                        <div class="item_title">所学专业</div>
                        <div class="item_input">
                            <van-field class="input_content"  v-model="form.internshipDesire.targetCity"  placeholder="请输入所学专业"/>
                            
                        </div>
                    </div>
                    
                    <div class="form_item_content">
                        <div class="item_title">毕业时间 <div><van-checkbox style="margin-left: 0.14rem;" v-model="form.internshipDesire.nowTime">至今</van-checkbox></div></div> 
                        <div class="item_input" >
                            <van-field class="input_item" v-model="form.educationalExperience.intakeTime" readonly clickable @click="dateShow=true" placeholder="开始时间"/>
                                <van-popup v-model="dateShow" position="bottom">
                                <van-datetime-picker  type="date"  @confirm="onDateConfirm($event, 'educationalExperience', 'intakeTime', 'dateShow')" title="选择年月日"/>
                                </van-popup>
                            <span class="line">-</span>
                            <van-field class="input_item"  v-model="form.educationalExperience.graduateTime" readonly clickable  @click="endDateShow = true" placeholder="结束时间"/>
                            <van-popup v-model="endDateShow" position="bottom">
                            <van-datetime-picker type="date" @confirm="onDateConfirm($event, 'educationalExperience', 'graduateTime', 'endDateShow')" />

                            </van-popup>
                        </div>
                    </div>
                    <div class="form_item_content" v-if="form.internshipDesire.nowTime == true">
                        <div class="item_title">所在年级</div>
                        <div class="item_input">
                            <van-field class="input_content"  v-model="form.educationalExperience.gradeName" readonly clickable name="picker" placeholder="请选择所在年级" @click="cityShowPicker = true"/>
                            <van-popup v-model="cityShowPicker" position="bottom">
                                <van-picker
                                    show-toolbar
                                    value-key="label"
                                    :columns="gradeColumns"
                                    @confirm="onGradeConfirm"
                                    @cancel="cityShowPicker = false"
                                />
                            </van-popup>
                            <div class="select_btn">请选择</div>
                        </div>
                    </div>
                    <div class="form_item_content">
                        <div class="item_title">是否有海外学习经历</div>
                        <div class="item_input">
                            <van-field class="input_content"  v-model="form.educationalExperience.isOverseasStudy" readonly clickable name="picker" placeholder="" />
                            <van-radio-group v-model="form.educationalExperience.isOverseasStudy" direction="horizontal">
                                <van-radio name="1">有</van-radio>
                                <van-radio name="0">无</van-radio>
                            </van-radio-group>
                        </div>
                    </div>
                </div>
            </div>
            <div class="show_tast">请填写国家承认的教育经历，非培训经历</div>
            
            <div style="margin: 0 0.10rem;">
                <van-button class="submmit_btn" round block type="info" native-type="submit">提交</van-button>
            </div>
        </van-form> -->
    </div>
</template>

<script>
import  TinternshipDesire from "./components/TinternshipDesire.vue"
import TeducationalExperience from "./components/TeducationalExperience"
import TworkExperience from "./components/TworkExperience.vue" // 工作
import TprojectExperience from "./components/TprojectExperience.vue" // 项目
import TlanguageAbility from "./components/TlanguageAbility.vue"  // 语言
import TspecialtyAbility from "./components/TspecialtyAbility.vue"  // 技能
import Tcertificates from "./components/Tcertificates.vue"  // 技能
import Tcourses from "./components/Tcourses.vue"  // 技能
import TpracticeExperience from "./components/TpracticeExperience.vue"  // 技能
import TuserInfo from "./components/TuserInfo.vue"  // 求职状态


import moment from 'moment'
export default {
    // 组件名称
    name: "demo",
    // 组件参数 接收来自父组件的数据
    props: {},

    // 局部注册的组件
    components: {
        TinternshipDesire,
        TeducationalExperience,
        TworkExperience,
        TprojectExperience,
        TlanguageAbility,
        TspecialtyAbility,
        Tcertificates,
        Tcourses,
        TpracticeExperience,
        TuserInfo,
    },
    data() {
        return {
            internshipDesire: false,
            educationalExperience: false,
            workExperience: false,
            projectExperience: false,
            languageAbility: false,
            specialtyAbility: false,
            certificates: false,
            courses: false,
            practiceExperience: false,
            userInfo: false,
            itemData: {},
            // statusShowPicker: false,
            // areaDictShowPicker: false,
            // cityShowPicker: false,
            // educationShowPicker: false,
            // dateShow: false,
            // endDateShow: false,
            // value: '',
            // columns: provinceAndCityData,
            // areaDict: AreaDict,
            // education: [], // 学历
            // gradeColumns: [], // 年级
            // postsStatus: [
            //     {
            //         label: '正在实习',
            //         children: [
            //             { label: '随时入职', value: '随时入职' },
            //             { label: '2周内入职', value: '2周内入职' },
            //             { label: '时间待定', value: '时间待定' },
            //         ]
            //     },
            //     {
            //         label: '暂无实习',
            //         children: [
            //             { label: '随时入职', value: '随时入职' },
            //             { label: '2周内入职', value: '2周内入职' },
            //             { label: '时间待定', value: '时间待定' },
            //         ]
            //     }
            // ],
            // form: {
            //     internshipDesire: {
            //         jobName: '',
            //         targetCity: '',
            //         expectedIndustry: '',
            //         lowestSalary: '',
            //         highestSalary: ''
            //     },
            //     educationalExperience: {
            //         educationalBackground: '', // 学历
            //         intakeTime: '',
            //         diploma: '', // 证书
            //         grade: '',
            //         graduateTime: '',
            //         major: '', // 专业
            //         schoolName: '',
            //         isOverseasStudy: '', // 海外
            //    }
            // }
            
        }
    },
    created() {
        console.log(this.$route.query, 'this.$route')
        if (this.$route.query) {
            this.setItemData(this.$route.query)
        }
        // console.log(provinceAndCityData)
        // this.seteducationOptions()

    },
    methods: {
        onItemData(e) {
            console.log(e)
            sessionStorage.setItem('formItem', e)
            // this.$route.params.FormItem = JSON.stringify(this.form)
            this.$router.back(-1)
            console.log(this.form)
        },
        setItemData(obj) {
            this[obj.objName] = true
            this.itemData = { ...JSON.parse(obj.data), objName: obj.objName, index: obj.index }
            console.log(this.itemData, '提交到组件的值')
        }
        // seteducationOptions() {
        //     this.education = educationOptions.map(item => {
        //         return {
        //             label: item.label,
        //             value: item.value,
        //             // children: item.this.education
        //             last:item.children
        //         }
        //     }).filter(item => item.value > 0)
        //     console.log(this.education, 'this.education')
        // },
        // onConfirm(val, va, vvv) {
        //     this.form.internshipDesire.targetCity = val[1]
        //     this.form.internshipDesire.cityIndex = va
        //     console.log(val, va, vvv)
        //     this.cityShowPicker = false
        // },
        // onSubmit(val) {
        //     console.log(val)
        // },
        // onConfirmAreaDict(val, va, vvv) {
        //     console.log(val, va, vvv)
        //     this.form.internshipDesire.expectedIndustry = this.areaDict[va[0]].children[va[1]]
        //     this.areaDictShowPicker = false

        //     console.log(val, va, vvv)
        // },
        // onConfirmStatus(val, va, vvv) {
        //     this.form.internshipDesire.jobName = val
        //     this.statusShowPicker = false

        //     console.log(val, va, vvv)

        // },
        // pickerConfirm(e, formItem,formKey, showKey) {
        //     this.form[formItem][formKey] = e.label
        //     this[showKey] = false
        //     // 学历对应的年级
        //     if (showKey == 'educationShowPicker') {
        //         console.log('------')
        //         this.gradeColumns = e.last
        //     }
        //     console.log(this.education)
        //     console.log(e, formItem, formKey, showKey)
        // },
        // // 时间组件
        // onDateConfirm(e, formItem, key, dataShow) {
        //     console.log(e, formItem, key, dataShow)

        //     this.form[formItem][key] = moment(e).format("YYYY-MM-DD")
        //     this[dataShow] = false
        //     console.log(moment(e[0]).format("YYYY-MM-DD"))

        // },
        // // 年级
        // onGradeConfirm(e, i, o, v) {
        //     this.form.educationalExperience.gradeName = e.label
        //     this.form.educationalExperience.gradeValue = e.value
        //     console.log(e, i, o, v)

        // }
    }
}
</script>

<style lang="less" scoped>


</style>